<html>
<head>
<title>Serial protocol</title>
</head>
<body>

<h2>Serial protocol</h2>
<p>Version: 0.2</p>
<p>Baud rate is user definable.</p>
<h3>Commands</h3>
<p>All commands are a single character followed by the command's parameters, 
if any. A command is terminated by &lt;cr&gt;&nbsp;(ASCII character 13). Line 
feed is ignored. Commands must not exceed 
30 chararacters total length. If a command of longer than 30 characters is received 
you will get the error &quot;Buffer overflow&quot;.&nbsp;All characters below 
32 (&lt;SPACE&gt;) are ignored and do not count towards the command length. 
When a value name is used, it is not case sensitive. 'FooValue' 
is the same as 'foovalue'. Commands are acknowledged by <B>OK&lt;cr&gt;&lt;lf&gt;</B>. 
The &lt;lf&gt; is optional.</p>
<B>g&lt;value name&gt;</B><ul>
    <p>Get the value of the variable. If it exists the number is returned as a 
numeric string. If it does not exist you get the error &quot;Value not 
found&quot;.<br>
e.g:<br>
</p>
    <table border="1">
        <tr>
            <td width="861">    <p>galtimeter.altitude</p>
            </td>
        </tr>
    </table>
</ul>
<ul>
    <p>returns something like: </p>
    <table border="1">
        <tr>
            <td width="861">
                <p>-1<br>ok</p>
            </td>
        </tr>
    </table>
</ul>
<p><B>s&lt;Value name&gt;=&lt;value&gt;</B></p>
<ul>
    <p>Set the value e.g<br></p>
    <table border="1">
        <tr>
            <td width="861">    <p>sSerialComms.UpdateRate=100</p>
            </td>
        </tr>
    </table>
</ul>
<p><B>l</B></p>
<ul>
    <p>
List all loaded modules and their values. Each module is listed in turn followed 
    by it's variables. The module name includes all of it's base classes separated 
    by dots. For example: <br>HMC5843.Compass3Axis.Compass.Module&lt;cr&gt;<br>Values 
    are listed in the following format:<br>&lt;space&gt;&lt;space&gt;&lt;class 
    name&gt;&lt;variable name&gt;&lt;space&gt;&lt;R/W&gt;&lt;space&gt;&lt;data 
    type&gt;&lt;cr&gt;<br>R/W is either the character 'R' for read only or 'W' 
    for read/write.<br>Data type is the socket's class name. See sockets.h for 
    more details<br>Other 
    data types may be added in the future.<br>The end of the list is indicated 
    by: <B>ok</B><br>Here is an example:<br>&nbsp;</p>
    <table border="1">
        <tr>
            <td>
                <p>FlightMode.Module<br>&nbsp;&nbsp;FlightMode.Status R Socket8<br>SCP1000.Altimeter.Module<br>&nbsp;&nbsp;Altimeter.Altitude 
                R SocketF<br>&nbsp;&nbsp;SCP1000.Filter W Socket8<br>&nbsp;&nbsp;SCP1000.Gain 
                W SocketF<br>HMC5843.Compass3Axis.Compass.Module<br>&nbsp;&nbsp;Compass.Heading 
                R SocketF<br>&nbsp;&nbsp;Compass3Axis.RawX R Socket16<br>&nbsp;&nbsp;Compass3Axis.RawY 
                R Socket16<br>&nbsp;&nbsp;Compass3Axis.RawZ R Socket16<br>&nbsp;&nbsp;Compass3Axis.Filter 
                W Socket8<br>ok</p>
            </td>
        </tr>
    </table>
</ul>
<p>&nbsp;</p>
<B>m</B>
<ul>
    <p>
Return the free memory in bytes.</p>
</ul>
<p><B>a&lt;value name&gt;</B></p>
<ul>
    <p>Append a value to the display list. The number of items is only limited 
by available memory.<br>
For example this would list the accelerometer values:<br></p>
    <table border="1">
        <tr>
            <td width="861">
                <p>c<br>aAccel.X<br>aAccel.Y<br>aAccel.Z<br>r</p>
            </td>
        </tr>
    </table>
</ul>
<p><B>c</B></p>
<ul>
    <p>
Clear the display list.</p>
</ul>
<p>
<B>r</B></p>
<ul>
    <p>
Keep sending the values in the display list until another command is 
received. Values are comma separated and always start with an asterisk '<B>*</B>'. The end of the line is indicated with 
    a  carriage return. For example the above command 
would output something like:<br>
 
</p>
    <table border="1">
        <tr>
            <td width="861">    <p>
*0, 1, 171<br>
*4, 5, 177<br>
*3, 3, 175<br>
*5, 5, 177<br>
*-1, 0, 171<br></p>
            </td>
        </tr>
    </table>
</ul>
<ul>
    <p>
You can set the rate by setting the variable 'SerialComms.UpdateRate'. A
 value of 100 would be every 100ms. Using a very high update rate could compromise 
    flight performance.</p>
</ul>
<p><B>p</B></p>
<ul>
    <p>Ping. Just returns <B>ok</B>.</p>
</ul>
<p><B>v</B></p>
<ul>
    <p>Return the firmware version number.</p>
</ul>
<p><B>writeEEPROM</B></p>
<ul>
    <p>Write all parameters to EEPROM memory. Actually this is the command 'w' 
    followed by 'riteEEPROM'. Returns ok once the EEPROM has been written.</p>
</ul>
<h3>&nbsp;Errors</h3>
<ul>
    <p>Modules may output error messages&nbsp;at any time. Errors always start 
    with&nbsp;'ERROR:' . For example:<br>ERROR: Value not 
found</p>
</ul>
<h3>Comments</h3>
<ul>
    <p>Comments are messages output by the flight controller that have no real 
    significance. For instance with the config software, comments are only displayed 
    on the serial console. Comments always start with hash '<B>#</B>'</p>
</ul>
</body>
</html>